<?php if(!defined('IN_APP')) exit('No direct script access allowed');

class Database
{
    private $dbi = array(
        'mysql',
        'mysqli'
    );
    
    public function __construct()
    {
        if(in_array(DB_INTERFACE, $this->dbi))
        {
            require_once "database/" . DB_INTERFACE . ".database." . EXT;
            $db = DB_INTERFACE . '_database';
            $this->db = new $db();
            $this->db->connect();
        }
    }
    
    public function __call($method_name, $args)
    {
        if(method_exists($this->db, $method_name))
        {
            return call_user_method_array($method_name, $this->db, $args);
        }
    }
    
    public function __get($var)
    {
        if(property_exists($this->db, $var))
            return $this->db->$var;
    }
}

/* EOF: Database.php */